//
//  UserViewController.m
//  UI_元旦豆瓣电影
//
//  Created by dllo on 15/12/31.
//  Copyright © 2015年 lanou3g. All rights reserved.
//

#import "UserViewController.h"
#import "EnterViewController.h"
#import "ShouCangViewController.h"
#import "ActivityModel.h"
#import "LjcDataBaseHandle.h"
@interface UserViewController ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, retain) UITableView *tableView;
@property (nonatomic, retain) NSArray *arrData;
@property (nonatomic, retain) NSMutableArray *arrActivity;
@end

@implementation UserViewController


-(void)dealloc {
    [_arrData release];
    [_tableView release];
    [super dealloc];
    
}

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
    }
    return self;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
        [self createNav];
    
        [self createTableView];
    
        [self button];
    
    
}


- (void)button {
    UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithTitle:@"登陆" style:UIBarButtonItemStylePlain target:self action:@selector(ItemAction:)];
    
    self.navigationItem.rightBarButtonItem = item;
    [item release];
}

- (void)ItemAction:(UIBarButtonItem *)bu {
    EnterViewController *EVC = [[EnterViewController alloc] init];

    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:EVC];
//    [self.navigationController pushViewController:EVC animated:YES];
    [self presentViewController:nav animated:YES completion:^{
        
    }];
    
    [EVC release];
    [nav release];
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _arrData.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
    cell.textLabel.text = _arrData[indexPath.row];
    return cell;
}








- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    ActivityModel *model = [ActivityModel activityModel];
    if (indexPath.row == 1) {
        ShouCangViewController *SVC = [ShouCangViewController alloc];
   
        [self.navigationController pushViewController:SVC animated:YES];
        [SVC release];
    }
    if (indexPath.row == 2) {
        
        [[LjcDataBaseHandle sharedDataBaseHandle] deleteTable:model];
    }
    
}



















- (void)createNav {
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBar.translucent = NO;
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0 green:0.4 blue:0.5 alpha:1];
    self.navigationItem.title = @"我的";

}

- (void)createTableView {
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain];
    [self.view addSubview:_tableView];
    [_tableView release];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    self.arrData = @[@"我的电影", @"我的活动", @"清除缓存"];
    
    self.arrActivity = [NSMutableArray array];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
